#pragma once

#include <QObject>
#include <QStringList>

#include "KeyInfo.h"
#include "Group.h"
#include "QGlobalShortcut.h"

namespace kryptos { namespace controller {

class Controller : public QObject
{
    Q_OBJECT

public:
    virtual ~Controller();

    static Controller& instance();

    kryptos::entities::GroupList contacts();

public slots:
    void viewIsReady();
    void getPassphraseForKey     (const kryptos::entities::KeyInfo& keyinfo);
    void getPassphraseForKeyAgain(const kryptos::entities::KeyInfo& keyinfo);

    void passphraseFromUserReady(const std::string& passphrase);

signals:
    void showApplication ();
    void hideApplication ();
    void passphraseNeeded(const std::string& name, const std::string& email);
    void wrongPassphrase (const std::string& name, const std::string& email);
    void passphraseReady (const std::string&);
    void encryptionOperationFinished();
    void keyOperationFinished();

private slots:
    void shortcutActivated();

private:
    Controller();
    void init();

    bool                           m_appActive;
    kryptos::util::QGlobalShortcut m_shorcut;
};

}}
